<?php
class JobfunctionsController extends AppController {

	var $name = 'Jobfunctions';
function  beforeFilter() {
            parent::beforeFilter();
            $this->Auth->autoRedirect = false;
            $this->set('active',3);
        }
	function index() {
		$this->Jobfunction->recursive = 0;
		$this->set('jobfunctions', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid jobfunction', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('jobfunction', $this->Jobfunction->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Jobfunction->create();
			if ($this->Jobfunction->save($this->data)) {
				$this->Session->setFlash(__('The jobfunction has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The jobfunction could not be saved. Please, try again.', true));
			}
		}
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid jobfunction', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Jobfunction->save($this->data)) {
				$this->Session->setFlash(__('The jobfunction has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The jobfunction could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Jobfunction->read(null, $id);
		}
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for jobfunction', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Jobfunction->delete($id)) {
			$this->Session->setFlash(__('Jobfunction deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Jobfunction was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
?>